package com.zhuss.team.information;

import com.zhuss.bean.bo.team.information.CreateInfoBo;
import com.zhuss.bean.bo.team.information.DeleteInfoBo;
import com.zhuss.bean.bo.team.information.UpdateInfoBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.WpsException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author: zhushanshuo
 * @Date: 2020/3/3 14:24
 */
@Component("informationOperateService")
public class InformationOperateService implements OperateService<Void,Object> {

    @Autowired
    @Qualifier("informationCreate")
    private Processor<Object, CreateInfoBo> informationCreate;

    @Autowired
    @Qualifier("informationUpdate")
    private Processor<Object, UpdateInfoBo> informationUpdate;

    @Autowired
    @Qualifier("informationDelete")
    private Processor<Object, DeleteInfoBo> informationDelete;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Void create(Object o) throws WpsException {
        CreateInfoBo bo = (CreateInfoBo) o;
        informationCreate.process(bo);
        return null;
    }

    @Override
    public Void update(Object o) throws WpsException {
        UpdateInfoBo bo = (UpdateInfoBo) o;
        informationUpdate.process(bo);
        return null;
    }

    @Override
    public Void delete(Object o) throws WpsException {
        DeleteInfoBo bo = (DeleteInfoBo) o;
        informationDelete.process(bo);
        return null;
    }
}
